home *** CD-ROM | disk | FTP | other *** search
- (set! *load-path* (cons ".." *load-path*))
- (require "blt")
-
- (define global list) ; Kludge
-
- ;;;;
- ;;;; Bitmap definitions
- ;;;;
- (blt_bitmap 'define 'pattern1 "((4 4) (01 02 04 08))")
- (blt_bitmap 'define 'pattern2 "((4 4) (08 04 02 01))")
- (blt_bitmap 'define 'pattern3 "((2 2) (01 02 ))")
- (blt_bitmap 'define 'pattern4 "((4 4) (0f 00 00 00))")
- (blt_bitmap 'define 'pattern5 "((4 4) (01 01 01 01))")
- (blt_bitmap 'define 'pattern6 "((2 2) (01 00 ))")
- (blt_bitmap 'define 'pattern7 "((4 4) (0f 01 01 01))")
- (blt_bitmap 'define 'pattern8 "((8 8) (ff 00 ff 00 ff 00 ff 00 ))")
- (blt_bitmap 'define 'pattern9 "((4 4) (03 03 0c 0c))")
- (blt_bitmap 'define 'hobbes "((25 25) (
- 00 00 00 00 00 00 00 00 00 c0 03 00 78 e0 07 00 fc f8 07 00 cc 07 04 00
- 0c f0 0b 00 7c 1c 06 00 38 00 00 00 e0 03 10 00 e0 41 11 00 20 40 11 00
- e0 07 10 00 e0 c1 17 00 10 e0 2f 00 20 e0 6f 00 18 e0 2f 00 20 c6 67 00
- 18 84 2b 00 20 08 64 00 70 f0 13 00 80 01 08 00 00 fe 07 00 00 00 00 00
- 00 00 00 00 ))")
-
- ;;;;
- ;;;; Default Colors
- ;;;;
- (option 'add "*Blt_htext.Font" "*Times-Bold-R*14*")
- (option 'add "*graph.xTitle" "X Axis Label")
- (option 'add "*graph.yTitle" "Y Axis Label")
- (option 'add "*graph.title" "A Simple Barchart")
- (option 'add "*graph.xFont" "*Times-Medium-R*12*")
- (option 'add "*graph.elemBackground" "white")
- (option 'add "*graph.elemRelief" "raised")
-
- (define visual (winfo 'screenvisual *root*))
- (unless (or (eq? visual 'staticgray) (eq? visual 'grayscale))
- (option 'add "*print.background" "yellow")
- (option 'add "*quit.background" "red"))
-
- (define (print-ps)
- (.graph 'postscript "bar.ps"
- :pagewidth '6.5i
- :pageheight '9i
- :landscape #t))
-
- ;;;;
- ;;;; Header hypertext
- ;;;;
- (blt_htext '.header :text "This is an example of the blt_barchart widget. The barchart has many components;
- x and y axis, legend, crosshairs, elements, etc.
- To create a postscript file \"bar.ps\", press the %%BEGIN
- (button '.header.print :text \"Print\" :command print-ps)
- (.header 'append .header.print)
- %% button.")
-
- ;;;;"
- ;;;; The barchart
- ;;;;
- (blt_barchart '.graph)
- (.graph 'xaxis 'configure :rotate 90 :command "FormatLabel")
-
-
- ;;;;
- ;;;; Footer hypertext
- ;;;;
-
- (blt_htext '.footer :text "Hit the %%BEGIN
- (button '.footer.quit :text \"quit\" :command (lambda ()(destroy *root*)))
- (.footer 'append .footer.quit)
- %% button when you've seen enough.%%BEGIN
- (label '.footer.logo :bitmap '|BLT|)
- (.footer 'append .footer.logo :padx 20)
- %%")
-
- ;;;;"
- ;;;; Callbacks
- ;;;;
- (define (TurnOnHairs graph)
- (bind graph "<Any-Motion>" '(|%W| 'crosshairs 'configure :position "@%x,%y")))
-
- (define (TurnOffHairs graph)
- (bind graph "<Any-Motion>" '(|%W| 'crosshairs 'configure :position "@%x,%y")))
-
- (bind .graph "<Enter>" '(TurnOnHairs |%W|))
- (bind .graph "<Leave>" '(TurnOffHairs |%W|))
-
- (define (FormatLabel w value)
- ;; Determine the element name from the value
- (let ((displaylist (w 'element 'show))
- (index (1- (inexact->exact (floor value)))))
- (list-ref displaylist index)))
-
-
- (define names '(One Two Three Four Five Six Seven Eight ))
- (define fgcolors '(red green blue purple orange brown cyan navy))
- (define bgcolors '(green blue purple orange brown cyan navy red))
- (define numColors (length names))
-
- (when (or (eq? visual 'staticgray) (eq? visual 'grayscale))
- (set! fgcolors '(white white white white white white white white ))
- (set! bgcolors '(black black black black black black black black )))
-
-
- (do ((i 0 (+ i 1)))
- ((= i numColors))
- (.graph 'element 'create (list-ref names i)
- :data (format #f "~A ~A" (+ i 1) (+ i 1))
- :fg (list-ref fgcolors i)
- :bg (list-ref bgcolors i)
- :stipple (format #f "pattern~A" (+ i 1))
- :relief "raised"
- :bd 2))
-
- (.graph 'element 'create 'Nine :data "9 -0.5" :fg "red" :relief "sunken")
- (.graph 'element 'create 'Ten :data "10 2" :fg "seagreen" :stipple "hobbes"
- :background "palegreen")
-
- (.graph 'element 'create 'Eleven :data "11 3.3" :fg "blue")
-
- (pack .header :padx 20 :pady 10)
- (pack .graph )
- (pack .footer :padx 20 :pady 10)
-
- (wm 'min *root* 0 0)
-
- ;;;;
- ;;;; Bindings
- ;;;;
-
- (define info "")
-
- (bind .graph "<B1-ButtonRelease>" (lambda (|W|)
- (|W| 'crosshairs 'toggle)))
- (bind .graph "<ButtonPress-3>" (lambda (|W| x y)
- (let ((info (|W| 'element 'closest x y)))
- (if (null? info)
- (blt_bell)
- (format #t "~A\n" info)))))
-
- (define (TurnOnHairs graph)
- (bind graph "<Any-Motion>" (lambda (|W| x y)
- (|W| 'crosshairs 'configure
- :position (format #f "@~A,~A" x y)))))
-
- (define (TurnOffHairs graph)
- (bind graph "<Any-Motion>" (lambda (|W| x y)
- (|W| 'crosshairs 'configure
- :position (format #f "@~A,~A" x y)))))
-
- (bind .graph "<Enter>" (lambda (|W|) (TurnOnHairs |W|)))
- (bind .graph "<Leave>" (lambda (|W|) (TurnOnHairs |W|)))
-
- ;;;;
- ;;;; FEATURES.TCL has not been rewritten for STk. If someone can do it....
- ;;;;